$(function(){
	jQuery.validator.addMethod("precision2", function(value, element) {
		var tel = /^[0-9]+(.[0-9]{1,2})?$/;
		return this.optional(element) || (tel.test(value));
	}, "该选项只能输入浮点数,且最多两位小数. 例: 8.88!");

	jQuery.validator.addMethod("stringCheck", function(value, element) {
		return this.optional(element) || /^[\u0391-\uFFE5\w]+$/.test(value);
	}, "只能包括中文字、英文字母、数字和下划线");

	jQuery.validator.addMethod("byteRangeLength", function(value, element,
			param) {
		var length = value.length;
		for ( var i = 0; i < value.length; i++) {
			if (value.charCodeAt(i) > 127) {
				length++;
			}
		}
		return this.optional(element)
				|| (length >= param[0] && length <= param[1]);
	}, "请确保输入的值在3-15个字节之间(一个中文字算2个字节)");

	jQuery.validator.addMethod("isIdCardNo", function(value, element) {
		// 简单验证
		var idCardNo = /^(\d{15}|\d{18}|\d{17}[x|X])$/;
		//return this.optional(element) || isIdCardNo(value);
		return this.optional(element) || idCardNo.test(value);
	}, "请正确输入您的身份证号码");

	jQuery.validator.addMethod("isMobile", function(value, element) {
		var length = value.length;
		var mobile = /^([\+][0-9]{1,3}[ \.\-])?([\(]{1}[0-9]{2,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/;
		return this.optional(element) || (mobile.test(value));
	}, "请正确填写您的手机号码");

	// 电话号码验证
	jQuery.validator.addMethod("isTel", function(value, element) {
		var tel = /^\d{3,4}-?\d{7,9}$/; // 电话号码格式010-12345678
		return this.optional(element) || (tel.test(value));
	}, "请正确填写您的电话号码");

	// 联系电话(手机/电话皆可)验证
	jQuery.validator.addMethod("isPhone", function(value, element) {
		var length = value.length;
		var mobile = /^(((13[0-9]{1})|(15[0-9]{1}))+\d{8})$/;
		var tel = /^\d{3,4}-?\d{7,9}$/;
		return this.optional(element)
				|| (tel.test(value) || mobile.test(value));
	}, "请正确填写您的联系电话");

	// 邮政编码验证
	jQuery.validator.addMethod("isZipCode", function(value, element) {
		var tel = /^[0-9]{6}$/;
		return this.optional(element) || (tel.test(value));
	}, "请正确填写您的邮政编码");
	
	jQuery.validator.addMethod("isBusiLicenseNo", function(value, element) {
		// 简单验证
		var busiLicNo = /^\d{15}$/;
		//return this.optional(element) || isIdCardNo(value);
		return this.optional(element) || busiLicNo.test(value);
	}, "请正确输入15位营业执照注册码");
	
	jQuery.validator.addMethod("isBankCard", function(value, element) {
		// 简单验证
		var bankCardReg = /^\d{15,19}$/;
		return this.optional(element) || ( bankCardReg.test(value) );
	}, "请输入15位至19位银行卡号");
	
	jQuery.validator.addMethod("isRegCode", function(value, element) {
		// 简单验证
		var regCodeRxp = /^\d{6}$/;
		return this.optional(element) || ( regCodeRxp.test(value) );
	}, "请输入6位数字验证码");
	
	jQuery.validator.addMethod("isPhoneValidCode", function(value, element) {
		// 简单验证
		var regCodeRxp = /^\d{4}$/;
		return this.optional(element) || ( regCodeRxp.test(value) );
	}, "请输入4位数字验证码");
	
	jQuery.validator.addMethod("pwdRules", function(value, element) {
		var pwd = /^[\@A-Za-z0-9\!\#\$\%\^\&\*\.\~\_\,]{6,26}$/;
		return this.optional(element) || (pwd.test(value));
	}, '密码由6-26位数字，大小字母，特殊字符组成');
	
	jQuery.validator.addMethod("fullNameRules", function(value, element) { 
		return this.optional(element) || (value.length<=42); 
	}, '全名长度不超过42位');

	jQuery.validator.addMethod("isIdCardNo", function(value, element) {
		// 简单验证
		var idCardNo = /^(\d{15}|\d{18}|\d{17}[x|X])$/;
		//return this.optional(element) || isIdCardNo(value);
		return this.optional(element) || idCardNo.test(value);
	}, "请正确输入您的身份证号码");
});